from wxpyview.ui.component.common.basewidget import *

class Menu(Widget):
    def _getParentParam(self, meta_widget):
        pass
    
    def _setParams(self, meta_widget):
        pass
        
    def create(self, meta_widget):
        self._setParams(meta_widget)
        
        dom = meta_widget.getDOM()
        if not dom:
            raise IOException

        label = dom.getAttribute("label")
        
        menu = wx.Menu()
        #self.params["parent"].SetMenuBar(menuBar)
        parent = meta_widget.getParentMetaWidget().getWidget()
        #parent.Append(menu, self.label)
        parent_classname = parent.__class__.__name__
        
        if parent_classname == "MenuBar":
            parent.Append(menu, label)
        elif parent_classname == "Menu":
            parent.AppendMenu(-1, label, menu)
        else:
            raise Exception
        
        return menu